File manager - Edit - /home/autoph/public_html/projects/AutoHub-Kiosk-Final/app/Console/Commands/SendSMS.php
Back
<?php namespace App\Console\Commands; use App\Http\Controllers\AdminController; use App\Models\Customer; use App\Models\Link; use Illuminate\Console\Command; use Illuminate\Support\Facades\Log; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; use App\Http\Controllers\SMSController; use App\Models\User; use App\Models\SmsResponse; class SendSMS extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'send:sms'; /** * The console command description. * * @var string */ protected $description = 'Send SMS'; /** * Execute the console command. * * @return int */ public function handle() { $array_data = []; $date_from = Carbon::now()->subDay(1)->startOfDay()->toDateTimeString(); $date_to = Carbon::now()->subDay(1)->endOfDay()->toDateTimeString(); $customer = Customer::whereBetween('created_at',[$date_from,$date_to])->distinct()->get(); foreach($customer as $info){ // Log::info($info); // return; $links = Link::select('link')->where('links_custId',$info['id'])->get(); $comp = explode("/",$links[0]->link); $comp_name = (new User())::select('comp_name')->where('token',$comp[5])->get(); $tinyURL = (new SMSController)->tinyUrl($links[0]->link); $subject = "Security Deposit"; $headers = "From: info@autohubgroup.com\r\n"; $headers .= "Content-Type: text/html\r\n"; $message = view('layouts.email.email',['comp_name'=>$comp_name[0]->comp_name,'customer'=>$info['fname']." ".$info['lname'],'url'=>$tinyURL])->render(); mail($info['email'],$subject,$message,$headers); if(empty($info['mobile'])){ } else { $array_data = [ "method" => "POST", "uri" => "https://api.autohub.ph/v1/sms/default", "key" => "b0d4111b7fff11edab53fa163e06960f", "mobile" => $info['mobile'], "message" => "Thank you for visiting ". $comp_name[0]->comp_name .". We are glad to assist you on your next vehicle purchase. To further serve you better, kindly visit the link below. Thank you. \nLink: ".$tinyURL, ]; $result = (new SMSController)->sendSMS($array_data); $status = json_decode($result,true); $db = DB::table('sms_response'); if($status['status'] == 0){ $db->insert([ 'cust_Id' => $info['id'], 'token' => $comp[5], 'url' => $tinyURL, 'mobile' => $info['mobile'], 'status' => $status['status'], 'message' => ucfirst(strtolower($status['message'])), 'created_at' => NOW() ]); } else { $statusResponse = json_decode($status['response'],true); $db->insert([ 'cust_Id' => $info['id'], 'token' => $comp[5], 'url' => $tinyURL, 'mobile' => $info['mobile'], 'status' => $status['status'], 'message' => "success", 'type' => $statusResponse['type'], 'transid' => $statusResponse['transid'], 'sms_length' => $statusResponse['sms_length'], 'sms_parts' => $statusResponse['sms_parts'], 'transaction_amount' => $statusResponse['transaction_amount'], 'telco' => $statusResponse['telco'], 'created_at' => NOW() ]); } } } } }
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings